package com.zbkj.crmeb.chant.controller;


import com.common.CommonPage;
import com.common.PageParamRequest;
import com.crmeb.core.common.CommonResult;
import com.zbkj.crmeb.chant.model.ChannelMerchantRenewal;
import com.zbkj.crmeb.chant.request.AddRenewalRequest;
import com.zbkj.crmeb.chant.response.ChannelMerchantRenewalResponse;
import com.zbkj.crmeb.chant.service.ChannelMerchantRenewalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商户续费记录表 前端控制器
 * </p>
 *
 * @author wuzp
 * @since 2022-08-03
 */
@RestController
@RequestMapping("/api/admin/renewal")
@Api(tags = "商户续费记录")
public class ChannelMerchantRenewalController {

    @Autowired
    private ChannelMerchantRenewalService channelMerchantRenewalService;

    @ApiOperation(value = "商户续费记录分页列表")
    @GetMapping(value = "/list")
    public CommonResult<CommonPage<ChannelMerchantRenewalResponse>> getRenewalList(Integer merId, PageParamRequest pageParamRequest){
        return CommonResult.success(CommonPage.restPage(channelMerchantRenewalService.getRenewalList(merId, pageParamRequest)));
    }

    @ApiOperation(value = "续费添加")
    @PostMapping(value = "/add")
    public CommonResult<Object> addRenewal(@RequestBody @Validated AddRenewalRequest request){
        return channelMerchantRenewalService.addRenewal(request) ? CommonResult.success() : CommonResult.failed();
    }

}

